//
//  MessageListCell.swift
//  VoiceRoom
//
//  Created by Rae on 2024/3/15.
//

import UIKit

class MessageListCell: UITableViewCell {

    private let iconImageView          = c_make_ex(UIImageView.self)
        .corner(25).mode(.scaleAspectFill).bgColor(.red).end()
    private let nameLabel          = c_make_ex(UILabel.self)
        .color(.white).font(16.font_semiBold).text("Janank").end()
    private let subLabel          = c_make_ex(UILabel.self)
        .color(.white.alpha(0.6)).font(14.font_medium).text("when we see a beautiful fl…").end()
    private let timeLabel          = c_make_ex(UILabel.self)
        .color(.white.alpha(0.3)).font(12.font_medium)
        .alignment(.right).text("2 min ago").end()
    private let numberLab          = LabelWithPadding()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.subviews {
            iconImageView
            nameLabel
            subLabel
            timeLabel
            numberLab
        }
        
        iconImageView.leading(25).size(50).centerVertically()
        nameLabel.leading(85).top(16.5).width(180)
        timeLabel.trailing(25)
        timeLabel.CenterY == nameLabel.CenterY
        subLabel.leading(85).trailing(85).top(46.5)
        numberLab.trailing(25).height(20)
        numberLab.CenterY == subLabel.CenterY
        
        numberLab.style { v in
            v.backgroundColor = "#FFFC00".toColor
            v.textColor = "#0F0112".toColor
            v.font = 12.font_semiBold
            v.padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
            v.layer.cornerRadius = 10
            v.layer.masksToBounds = true
            v.text = "5"
        }
    }

    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
